<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page errorPage="../jsp/index.jsp?site=error"%>
<%@page import="java.util.HashMap"%>
<%@page import="de.fhhof.vinf.ssp.studienarbeit11.beans.SaveStrings"%>
<%@page import="java.util.ArrayList"%>

<jsp:useBean id="SaveStrings"
	class="de.fhhof.vinf.ssp.studienarbeit11.beans.SaveStrings"
	scope="session" />
<%!
	/*
	 *This Method prepares Strings for the <input value= ... > fields
	 */
	public String prepareString(String input) {
		if (input == null || input.equals("")) {
			return " ";
		} else {
			return "value=" + input;
		}
	}
%>

<%
	/*
	 *Wrong input is written 
	 *List generated at checkRegister.jsp and written to the session scope
	 */
	ArrayList<String> ArrayList = SaveStrings.getArraylist();
	for (String s : ArrayList) {
		out.write(s.toString() + "<br/>");
	}

	/*
	 *If user does a valid input checkRegister.jsp saves the input in a HashMap
	 *and writes it to the session scope. The HashMap is used to prelocate 
	 *the texfields in the formular
	 */
	HashMap<String, String> hashMap = SaveStrings.getHashMap();
%>
<br />


<form
	action="<%=response.encodeURL("../includejsp/checkRegister.jsp")%>"
	method="post">

	<table>
		<tr>
			<td>First name:</td>
			<td><input type="text" name="first_name"
				<%=prepareString(hashMap.get("first_name"))%> /></td>
		</tr>
		<tr>
			<td>Last name:</td>
			<td><input type="text" name="last_name"
				<%=prepareString(hashMap.get("last_name"))%> /></td>
		</tr>
		<tr>
			<td>E-mail:</td>
			<td><input type="text" name="email"
				<%=prepareString(hashMap.get("email"))%> /></td>
		</tr>
		<tr>
			<td>Password:</td>
			<td><input type="password" name="password" /></td>
		</tr>
		<tr>
			<td>Validate password:</td>
			<td><input type="password" name="password2" /></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" value="Register" class="button" /></td>
		</tr>
	</table>
</form>